﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

namespace Staionery_Inventory
{
    public partial class master : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["empID"] == null)
            {
                Response.Redirect("~/Presentation/login.aspx");
            }
            if ((string)Session["role"] == "Employee" && (string)Session["Department"] != "STORE")
            {
                xdstreeview.DataFile = "~/xml/Employee.xml";
            }
            else if ((string)Session["role"] == "Employee" && (string)Session["Department"] == "STORE")
            {
                xdstreeview.DataFile = "~/xml/StoreClerk.xml";
            }
            else if ((string)Session["role"] == "Head" && (string)Session["Department"] == "STORE")
            {
                xdstreeview.DataFile = "~/xml/StoreManager_or_Supervisor.xml";
            }
            else if ((string)Session["role"] == "Supervisor" )
            {
                xdstreeview.DataFile = "~/xml/StoreManager_or_Supervisor.xml";
            }
            else if ((string)Session["role"] == "Head" && (string)Session["Department"] != "STORE")
            {
                xdstreeview.DataFile = "~/xml/DeptHead.xml";
            }
            else if ((string)Session["role"] == "Admin")
            {
                xdstreeview.DataFile = "~/xml/Adminstrator.xml";
            }
        }
        public String LoginName
        {
            get { return lblLogInName.Text; }
            set { lblLogInName.Text = value; }
        }

        protected void hllogout_Click(object sender, EventArgs e)
        {
            Session.Abandon();
            FormsAuthentication.SignOut();
            HttpCookie cookie1 = new HttpCookie(FormsAuthentication.FormsCookieName, "");
            cookie1.Expires = DateTime.Now.AddYears(-1);
            Response.Cookies.Add(cookie1);
            // clear session cookie (not necessary for your current problem but i would recommend you do it anyway)
            HttpCookie cookie2 = new HttpCookie("ASP.NET_SessionId", "");
            cookie2.Expires = DateTime.Now.AddYears(-1);
            Response.Cookies.Add(cookie2);
            FormsAuthentication.RedirectToLoginPage();
           //Response.Redirect("~/Presentation/login.aspx");
        }
    }
}